﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZGLXM.ErrorCode;
using ZGLXM.Read.Api.Applicantion.Command.RBAC;

namespace ZGLXM.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleController : ControllerBase
    {
        private readonly IMediator mediator;
        public RoleController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 角色列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetRole([FromQuery] GetRoleCommand param)
        {
            return await mediator.Send(param);
        }

        /// <summary>
        /// 获取角色信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> RoleById([FromQuery] RoleByIdCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
